page.tsx 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import { Suspense } from "react";
  2. import { notFound } from "next/navigation";
  3. import { getLayoutConfiguration } from "@/app/actions/layout-configurations";
  4. import { LayoutConfigurationDetail } from "@/app/components/layout-configurations/LayoutConfigurationDetail";
  5. import { Skeleton } from "@/components/ui/skeleton";
  6. interface PageProps {
  7. params: Promise<{
  8. id: string;
  9. }>;
  10. }
  11. export default async function LayoutConfigurationDetailPage({ params }: PageProps) {
  12. const p = await params;
  13. const id = parseInt(p.id);
  14. if (isNaN(id)) {
  15. notFound();
  16. }
  17. const result = await getLayoutConfiguration(id);
  18. if (!result.success || !result.data) {
  19. notFound();
  20. }
  21. const configuration = result.data;
  22. return (
  23. <div className="container mx-auto py-8 px-4">
  24. <div className="mb-6">
  25. <h1 className="text-3xl font-bold">{configuration.name}</h1>
  26. <p className="text-muted-foreground">
  27. Created: {new Date(configuration.createdAt).toLocaleDateString()}
  28. </p>
  29. </div>
  30. <Suspense fallback={<LayoutConfigurationDetailSkeleton />}>
  31. <LayoutConfigurationDetail configuration={{
  32. ...configuration,
  33. createdAt: configuration.createdAt,
  34. updatedAt: configuration.updatedAt,
  35. sections: configuration.sections.map((section: any) => ({
  36. ...section,
  37. startingRow: section.startingRow ?? undefined,
  38. endingRow: section.endingRow ?? undefined,
  39. fields: section.fields.map((field: any) => ({
  40. ...field,
  41. dataTypeFormat: field.dataTypeFormat ?? null
  42. }))
  43. }))
  44. }} />
  45. </Suspense>
  46. </div>
  47. );
  48. }
  49. function LayoutConfigurationDetailSkeleton() {
  50. return (
  51. <div className="space-y-6">
  52. <Skeleton className="h-8 w-64" />
  53. <Skeleton className="h-4 w-32" />
  54. <Skeleton className="h-32 w-full" />
  55. </div>
  56. );
  57. }